package iedcyt.acute.controller.listeners.author;

import iedcyt.acute.model.AuthorModel;
import iedcyt.acute.view.AuthorView;
import iedcyt.acute.view.ViewUtils;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public class DocumentsKeyDownListener implements Listener {

	private AuthorModel _model;
	private AuthorView _view;
	/**
	 * Se inicializa el controlador registrando la vista y el modelo
	 * @param view
	 * @param model
	 */
	public DocumentsKeyDownListener(AuthorView view, AuthorModel model) {
		this._model = model;
		this._view = view;
	}
	/**
	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
	 */
	public void handleEvent(Event event) {
		
		Integer idDoc = _model.getSelected_IdDoc();
		
		if (idDoc != null)
		{
		//al pulsar 'a' se abre el documento
		if (event.character == 'a')
		{
			ViewUtils.getInstance().openDocumentView(idDoc);
		}
		}
		
	}
}
